package com.alperez.androidsmscamera.model;

import android.text.TextUtils;

public class SmsResponse {
	private CommandType commandType;
	private String commandUUID; // This field is used to substitute response to the request
	private boolean success;	// This value is not contained in JSON representation and is calculated based on resultCode
	private long timeResponse;
	private CommandResultCode resultCode;
	private String responseText;	// This fields depends on commandType and success fields.
									// If success is true - this field is a String representation of JSON response payload,
									// which format depends on commandType. If success is false, this field is a plain text with error message
	
	
	/**
	 * 
	 * @param resultCode the result of the command for which this response is provided<br>
	 * result can not be null.
	 */
	public SmsResponse(CommandResultCode resultCode) {
		if (resultCode == null) {
			throw new IllegalArgumentException("Result code must be provided");
		}
		this.resultCode = resultCode;
	}
	
	public CommandType getCommandType() {
		return commandType;
	}

	public void setCommandType(CommandType commandType) {
		this.commandType = commandType;
	}
	
	public String getCommandUUID() {
		return commandUUID;
	}

	public void setCommandUUID(String commandUUID) {
		this.commandUUID = commandUUID;
	}

	public boolean isSuccess() {
		return success;
	}
	
	public void setSuccess(boolean success) {
		this.success = success;
	}

	public long getTimeResponse() {
		return timeResponse;
	}

	public void setTimeResponse(long timeResponse) {
		this.timeResponse = timeResponse;
	}

	public CommandResultCode getResultCode() {
		return resultCode;
	}

	public String getResponseText() {
		return responseText;
	}

	public void setResponseText(String responseText) {
		this.responseText = responseText;
	}
	
	@Override
	public String toString() {
		if (TextUtils.isEmpty(responseText)) {
			return "success=" + success + "; message - not provided";
		} else {
			return "success=" + success + "; message = "+responseText;
		}
	}

	
}
